package neusoft.edu.cn.a215lmeordering.Listener;


import com.baidu.location.BDAbstractLocationListener;
import com.baidu.location.BDLocation;

import neusoft.edu.cn.a215lmeordering.iface.LocationIface;

public class MyLocationListener extends BDAbstractLocationListener {

    String addr;
    String country;
    String province;
    String city;
    String district;
    String street;
    String locationDescribe;
    double latitude;
    double longitude;
    double radius;
    int errorCode;

    private LocationIface locationIface;

    public void setListener(LocationIface updateLocationUI){

        this.locationIface = updateLocationUI;
    }

    @Override
    public void onReceiveLocation(BDLocation bdLocation) {
        //此处的BDLocation为定位结果信息类，通过它的各种get方法可获取定位相关的全部结果
        //以下只列举部分获取地址相关的结果信息
        //更多结果信息获取说明，请参照类参考中BDLocation类中的说明

        addr = bdLocation.getAddrStr();    //获取详细地址信息
        country = bdLocation.getCountry();    //获取国家
        province = bdLocation.getProvince();    //获取省份
        city = bdLocation.getCity();    //获取城市
        district = bdLocation.getDistrict();    //获取区县
        street = bdLocation.getStreet();    //获取街道信息
        locationDescribe = bdLocation.getLocationDescribe();
        latitude = bdLocation.getLatitude();    //获取纬度信息
        longitude = bdLocation.getLongitude();    //获取经度信息
        radius = bdLocation.getRadius();    //获取定位精度，默认值为0.0f
        errorCode = bdLocation.getLocType();
        //获取定位类型、定位错误返回码，具体信息可参照类参考中BDLocation类中的说明

        if (locationIface != null){
            locationIface.getResultList(addr);
        }

    }


}
